package client;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;

import javax.swing.*;

public class Mappagenerale extends JPanel implements Serializable {

	private JLabel[][] caselle;
	
	private ImageIcon terra=new ImageIcon( "terra.gif");
	private ImageIcon vegetazione=new ImageIcon("vegetazione.gif");
	private ImageIcon acqua=new ImageIcon("acqua.gif");
	private ImageIcon buio=new ImageIcon("buio.gif");
	private ImageIcon dinosauro=new ImageIcon("yellow.gif");
	
	
	public Mappagenerale(char[][] visuale){
		
		setSize(900,700);
		setLayout(new GridLayout(40,40));
		
		caselle = new JLabel[40][40];
		for (int i=0;i<40;i++)
			for (int j=0;j<40;j++){
				caselle[i][j]= new JLabel();
				caselle[i][j].setPreferredSize(new Dimension(15, 15));
				caselle[i][j].setBounds(1, 1, 15, 15);
				add(caselle[i][j]);
			}
		
		refreshMappa(visuale);

		validate();
		setVisible(true);
	}
	
	public ImageIcon refresh(char v){

			switch(v){
			
			case('b'):
				return buio;
				
			case('t'):
				return terra;
				
			case('a'):
				return acqua;
				
			case('v'):
				return vegetazione;
			
			case('c'):
				return terra;
			
			case('y'):
				return dinosauro;
			}
			
		return buio;
		
	}

	public void refreshMappa(char[][] visuale){
		for (int i=0;i<40;i++)
			for (int j=0;j<40;j++){
				caselle[i][j].setIcon( refresh(visuale[i][j]));
			}
	}
	
}
